import {get, post, postFormData} from '@/request/http'
import store from '@/store'

//上传图片
export const UploadPictureByUUID = ({file}) => {
  let formData = new FormData()
  formData.append('image', file)

  return postFormData('/FTKJWLHYPT/Api/UploadImage', formData)
}
// 运单列表
export const getWillBillList = ({
  orderCode = '',
  billCode = '',
  billStatus = '',
  trkCode = '',
  driver = '',
  PageIndex,
  PageSize,
  wabType
}) => {
  return post('/FTKJWLHYPT/transoprt/getWayBillList', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          attCode: orderCode,
          wabCode: billCode,
          wabStatus: billStatus,
          trkNo: trkCode,
          drvName: driver,
          fltUuid: store.state.user.FLT_UUID_DX_H,
          wabType
        }
      },
      Orderbys: {},
      PageIndex: {
        FTKJWLHYPT: PageIndex
      },
      PageSize: {
        FTKJWLHYPT: PageSize
      }
    }
  })
}

// 撤销运单接口
export const undoWayBill = ({
  waybill
}) => {
  return post('/FTKJWLHYPT/transoprt/undoWayBill', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          uuid: waybill.uuid,
          attUuid: waybill.attUuid,
          wabWeight: waybill.WAB_WEIGHT,
          wabGoodsId: waybill.wabGoodsId,
          lastmodifier: store.state.user.USR_CODE_DX_H,
          fltUuid: store.state.user.FLT_UUID_DX_H
        }
      }
    }
  })
}
// 编辑运单接口
export const editWillBill = ({
  uuid,
  attUuid,
  attCode,
  wabStatus,
  wabUuid,
  wabCode,
  wabCtrNo,
  wabSealNo,
  wabProBatch,

}) => {
  return post('/FTKJWLHYPT/transoprt/editWayBill', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          attUuid,
          attCode,
          uuid: String(uuid),
          lastmodifier: store.state.user.USR_CODE_DX_H,
          wabStatus,
          wabUuid,
          wabCode,
          wabCtrNo,
          wabSealNo,
          wabProBatch,
          fltUuid: store.state.user.FLT_UUID_DX_H
        }
      }
    }
  })
}

// 运单动态列表
export const getWillBillStatus = ({
  wabUuid
}) => {
  return post('/FTKJWLHYPT/transoprt/getwabOperationList', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          optEtpId: store.state.user.FLT_UUID_DX_H,
          wabUuid
        }
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT: '1'
      },
      PageSize: {
        FTKJWLHYPT: '30'
      }
    }
  })
}
// 运单节点动态列表
export const getWabActivitesSer = ({
  wabUuid
}) => {
  return post('/FTKJWLHYPT/frtOrder/getWabActivitesModelList',
    {
      lacWabId: wabUuid
    })
}
//运单节点动态录入 保存
export const  saveNodeDycSer=(data) =>
  post (
    '/FTKJWLHYPT/frtOrder/saveNodeDyc',
    {
      lacCtrId:data.lacCtrId, //箱ID
      lacGdsId :data.lacGdsId, //货Id
      lacWabId:data.lacWabId, //运单ID
      lacOpprc:data.lacOpprc,   //动作
      lacOptm:data.lacOptm, // 作业开始时间
      lacOpendtm:data.lacOpendtm, // 作业结束时间
      lacAddress:data.lacAddress, //作业开始地点
      lacEndAddress:data.lacEndAddress, //作业结束地点
      lacContent:data.lacContent,  //内容
      lacShipName:data.lacShipName,  //船名
      lacVoyage:data.lacVoyage,  //航次
      lacCreater:store.state.user.USR_CODE_DX_H,  //操作人
      lacRemark:data.lacRemark,   //备注
      lacInId:data.lacInId,  //录入id
      lacFb:data.lacFb, //是否发布
      lacAta:data.lacAta, //实际到港时间
      lacDof:data.lacDof, //放货时间
      lacDod:data.lacDod, //送货时间
      lacSignNum:data.lacSignNum, //签到数量
    }
  )
//运单节点动态编辑
export const  editNodeDycSer=(data) =>
  post (
    '/FTKJWLHYPT/frtOrder/editNodeDyc',
    {
      lacId: data.lacId, //节点动态Id
      lacCtrId:data.lacCtrId, //箱ID
      lacGdsId :data.lacGdsId, //货Id
      lacWabId:data.lacWabId, //运单ID
      lacOpprc:data.lacOpprc,   //动作
      lacOptm:data.lacOptm, // 作业时间
      lacOpendtm:data.lacOpendtm, // 作业结束时间
      lacAddress:data.lacAddress, //作业地点
      lacEndAddress:data.lacEndAddress, //作业结束地点
      lacContent:data.lacContent,  //内容
      lacShipName:data.lacShipName,  //船名
      lacVoyage:data.lacVoyage,  //航次
      lacLstupduser:store.state.user.USR_CODE_DX_H, //操作人
      lacRemark:data.lacRemark,   //备注
      lacInId:data.lacInId,  //录入id
      lacFb:data.lacFb, //是否发布
      lacAta:data.lacAta, //实际到港时间
      lacDof:data.lacDof, //放货时间
      lacDod:data.lacDod, //送货时间
      lacSignNum:data.lacSignNum, //签到数量
    }
  )
//运单节点动态删除
export const  delNodeDycSer=(data) =>
  post (
    '/FTKJWLHYPT/frtOrder/delNodeDyc',
    {
      lacId: data.lacId, //节点动态Id
    }
  )

// 异常反馈查看
export const feedbackList = ({
  fbPhone,
  fbDrivername,
  fbAddress,
  PageIndex,
  PageSize
}) => {
  return post('/FTKJWLHYPT/transoprt/findFeedback', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          fltUuid: store.state.user.FLT_UUID_DX_H,
          fbPhone,
          fbDrivername,
          fbAddress
        }
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT: PageIndex
      },
      PageSize: {
        FTKJWLHYPT: PageSize
      }
    }
  })
}
// 上传图片的接口
export const uploadReceiptServer = ({file, wabUuid}) => {
  // 构建 formData 对象
  let formData = new FormData()
  formData.append('callback', '')
  formData.append('type', '')
  formData.append('name', '')
  formData.append('url', '')
  formData.append('image', file)
  formData.append('wabUuid', wabUuid)
  formData.append('operor', store.state.user.USR_CODE_DX_H)

  return postFormData('/FTKJWLHYPT/transoprt/uploadReceipt', formData)
}
// 查看图片 多个
// export const getReceiptServer = ({wattcWabId}) => {
//   // 构建 formData 对象
//   let formData = new FormData()
//   formData.append('wattcWabId', wattcWabId)

//   return postFormData('/FTKJWLHYPT/transoprt/getReceipt', formData)
// }
// 查看图片多个
export const getReceiptServer = ({
  wattcWabId,
}) => {
  return post('/FTKJWLHYPT/transoprt/getReceipt',
    {
          wattcWabId,
        })
}


// // 查看图片单个
// export const getReceiptServerD = ({wattcWabId,wattcWabStatus}) => {
//   // 构建 formData 对象
//   let formData = new FormData()
//   formData.append('wattcWabId', wattcWabId)
//   formData.append('wattcWabStatus', wattcWabStatus)

//   return postFormData('/FTKJWLHYPT/transoprt/getReceipt', formData)
// }

// 查看图片单个
export const getReceiptServerD = ({
  wattcWabId,
  wattcWabStatus
}) => {
  return post('/FTKJWLHYPT/transoprt/getReceipt',
    {
          wattcWabId,
          wattcWabStatus,
    })
}
export const downloadDynamicNodeSer = () =>
  get(
    '/FTKJWLHYPT/frtOrder/downloadDynamicNode'
  )


  // 查看图片单个
export const   auditWayBill= ({
  uuid,
}) => {
  return post('/FTKJWLHYPT/transoprt/auditWayBill',
  {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          uuid,
          lastmodifier: store.state.user.USERNAME_DX_H,
        }
      }
    }
  })
}
